package com.f6.service;

import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.f6.utils.HttpClientUtil;
import com.f6.utils.SystemConstans;
import com.f6.weixin.common.vo.WeixinTokenVO;

@Service("weixintokenservice")
public class WeiXinTokenService {

	public WeixinTokenVO getToke() {
		WeixinTokenVO weixintoken = null;
		String url = SystemConstans.WEIXINURL;

		Map<String, String> params = new HashMap<String, String>();
		params.put("grant_type", "client_credential");

		params.put("appid", SystemConstans.APPID);
		params.put("secret", SystemConstans.APPSECRET);
		try {
			String token = HttpClientUtil.httpGetRequest(url, params);
			weixintoken = JSONObject.parseObject(token, WeixinTokenVO.class);

		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return weixintoken;
	}
  public static void main(String[] args) {
	  WeiXinTokenService se = new WeiXinTokenService();
	  WeixinTokenVO tt = se.getToke();
	  System.out.println(tt);
}
}
